package domain;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Entity
@Access(AccessType.PROPERTY)
public class ShoppingCartItemUnit extends DomainEntity {

	// Constructors
	public ShoppingCartItemUnit() {
		super();
	}

	// Attributes

	private int numberOfItems;

	@Min(0)
	public int getNumberOfItems() {
		return numberOfItems;
	}

	public void setNumberOfItems(int numberOfItems) {
		this.numberOfItems = numberOfItems;
	}

	// Relationships

	private Customer customer;
	private AvailableItem availableItem;

	@NotNull
	@Valid
	@ManyToOne(optional = false)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@NotNull
	@Valid
	@ManyToOne(optional = false)
	public AvailableItem getAvailableItem() {
		return availableItem;
	}

	public void setAvailableItem(AvailableItem availableItem) {
		this.availableItem = availableItem;
	}

}
